package com.im.manage.handler;


import com.im.api.bean.ServerAddress;
import com.im.manage.IMConstants;
import com.im.manage.bean.Head;
import com.im.manage.bean.chat.Content;
import com.only.common.lib.util.HttpClient3Util;
import com.only.common.lib.util.OnlyJsonUtil;
import com.im.manage.bean.Message;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;



/**
 * @author: XiaHui
 * @date: 2016年10月20日 下午4:05:02
 */
public class ChatHandler {

	String baseUrl = IMConstants.baseUrl;

    public String roomChatInfo(String roomId,ServerAddress userData,Content content) {
        String result = null;
        Head head = new Head();
        head.setAction("chat");
        head.setMethod("roomChatInfo");
        Message message = new Message();
        message.setHead(head);
        message.put("roomId", roomId);
        message.put("userData", userData);
        message.put("content", content);
        String data = OnlyJsonUtil.objectToJson(message);

        
        
        JSONObject auth = new JSONObject();
		auth.put("id", "own-000001");
		auth.put("key", "kkkyyyttt");
		try {

			String url = baseUrl + "/web/api.do";
			Map<String, String> dataMap = new HashMap<String, String>();
			dataMap.put("auth", auth.toJSONString());
			dataMap.put("data", data);
			result = HttpClient3Util.post(url, dataMap);
		} catch (Exception e) {
			// e.printStackTrace();
		}
        return result;
    }
}
